<?php
namespace app\admin\controller;
use think\Request;
use app\admin\model\Qx as Qxs;
use think\Controller;
use think\Db;

/**
 * 场馆器械控制器
 */
class Qx extends Common
{
    private $cModel; //当前控制器关联模型

    public function _initialize()
    {
        parent::_initialize();
        $this->cModel = new Qxs;;
    }
    public function index()
    {
        $dataList = $this->cModel->select();
        $this->assign('dataList', $dataList);
        return $this->fetch();
    }

    public function create()
    {
        return $this->fetch();

    }

    public function add()
    {
        $data = $this->params;
        $data['create_at'] = time();
        dump($data);die;
        $res = $this->cModel->save($data);
    }

    public function edit()
    {
        // $id =empty(input('get.id')) ? ajaxReturn2(-1, 'id is missing') : input("get.id") ;
        $data = array(
                'id'      =>2,
                'qx_name' =>'跑步机2',
                'kc_name' =>'瑜伽2',
                'create_at' =>time(),
                );
        $res = $this->cModel->where(['id'=>2])->update($data);

        dump($res);

    }

    public function delete()
    {
        $id = input('get.id');
        $res = $this->cModel->where(['id'=>$id])->delete();
        dump($res);
    }
}